package cn.bdqn.controller.wx;

import cn.bdqn.entity.UserInfo;
import cn.bdqn.service.wx.SignService;
import cn.bdqn.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ProjectName: ycbdqn
 * @Package: cn.bdqn.controller.wx
 * @Author: huat
 * @Date: 2020/3/3 22:46
 * @Version: 1.0
 */
@RestController
@RequestMapping("wx")
public class SignController {
    @Autowired
    SignService signService;
    @Autowired
    WebSocketServer webSocketServer;

    /**
     * 获取广告图片url
     * @return
     */
    @RequestMapping("getSignImageUrl")
    public String getSignImageUrl(){
        return signService.getSignImageUrl();
    }

    /**
     * 增加用户通过form表单
     * @param realName 姓名
     * @param phoneNumber 手机号
     * @return
     */
    @PostMapping("addUserByForm")
    public boolean addUserByForm(String realName,String phoneNumber){
        boolean flag= signService.addUserByForm( realName, phoneNumber);
        if(flag){
            webSocketServer.sendMessage("1");
        }
        return flag;
    }
}
